Fixed timezones for scheduler

Maximilian Clarke 11 anni fa
parent
commit
0f0208a608
1 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 4 2
      bin/schedule.rb

+ 4 - 2
bin/schedule.rb

@@ -50,6 +50,8 @@ class HuginnScheduler
50 50
 
51 51
     rufus_scheduler = Rufus::Scheduler.new
52 52
 
53
+    tzinfo_friendly_timezone = ActiveSupport::TimeZone::MAPPING[ENV['TIMEZONE'].present? ? ENV['TIMEZONE'] : "Pacific Time (US & Canada)"]
54
+
53 55
     # Schedule event propagation.
54 56
 
55 57
     rufus_scheduler.every '1m' do
@@ -58,7 +60,7 @@ class HuginnScheduler
58 60
 
59 61
     # Schedule event cleanup.
60 62
 
61
-    rufus_scheduler.cron "0 0 * * * America/Los_Angeles" do
63
+    rufus_scheduler.cron "0 0 * * * " + tzinfo_friendly_timezone do
62 64
       cleanup_expired_events!
63 65
     end
64 66
 
@@ -74,7 +76,7 @@ class HuginnScheduler
74 76
 
75 77
     # Times are assumed to be in PST for now.  Can store a user#timezone later.
76 78
     24.times do |hour|
77
-      rufus_scheduler.cron "0 #{hour} * * * America/Los_Angeles" do
79
+      rufus_scheduler.cron "0 #{hour} * * * " + tzinfo_friendly_timezone do
78 80
         if hour == 0
79 81
           run_schedule "midnight"
80 82
         elsif hour < 12